class DataSet
  
  def initialize
    @h_table = {}
    @data = []
    @empty = :empty
  end
  
  attr_reader :empty, :h_table
  
  #
  ## return Array of Arrays of numbers
  def get_data_from(fname)
    return @data unless @data.empty?
    
    file = File.open fname
    file.each_line do |line| 
      @data << line.split.collect do |el|
        el.to_i
      end
    end
    
    @data.flatten!
  end # - get_data_from(fname)
  
  #
  ##
  def to_hash
    return @h_table unless @h_table.empty?
    
    @data.each do |el|
      @h_table[el] = @empty
    end
    
    @h_table
  end # - to_hash
  
  #
  ##
  def has_pair_for_target_sum?(sum)
    to_hash.each_key do |n|
      if @h_table.has_key?(sum - n)
        return true
      end
    end
    
    false
  end
  
end # - DataSet